# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=eaphammer
pkgver=v1.14.1.r0.g91e8956
pkgrel=4
epoch=1
pkgdesc='Targeted evil twin attacks against WPA2-Enterprise networks. Indirect wireless pivots using hostile portal attacks.'
groups=('blackarch' 'blackarch-wireless')
arch=('any')
url='https://github.com/s0lst1c3/eaphammer'
license=('GPL3')
depends=('python' 'python-tqdm' 'dnsmasq' 'libnfnetlink' 'libnl' 'openssl'
         'python-pem' 'python-pyopenssl' 'apache' 'libpcap' 'curl' 'scapy'
         'responder' 'hcxtools' 'hcxdumptool' 'python-beautifulsoup4'
         'python-flask' 'python-flask-cors' 'python-flask-socketio'
         'python-gevent' 'python-lxml' 'python-requests' 'python-pywebcopy')
makedepends=('git')
source=("git+https://github.com/s0lst1c3/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
    sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  cd "$pkgname/local/hostapd-eaphammer/hostapd"

  cp defconfig .config
  make hostapd-eaphammer_lib
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md Changelog
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

